package com.yidu.best.systemManagement.systemLog.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yidu.best.systemManagement.systemLog.dao.LogDao;
import com.yidu.best.systemManagement.systemLog.domian.Log;
import com.yidu.best.systemManagement.systemLog.domian.LogVo;
import com.yidu.best.systemManagement.systemLog.service.LogService;

@Service
public class LogServiceImpl implements LogService {
	@Autowired
	private LogDao logDao;

	@Override
	public Map<String, Object> findPageQueryLog(LogVo logVo) {
		// 调用dao层方法查询数量
		int count = logDao.findCountLog(logVo);
		// 计算页码
		int page = (logVo.getPage() - 1) * logVo.getLimit();
		logVo.setPage(page);
		// 调用dao层方法分页查询
		List<Log> logList = logDao.findPageQueryLog(logVo);
		Map<String, Object> map = new HashMap<String, Object>();
		// 将数据存入map中
		map.put("code", 0);
		map.put("count", count);
		map.put("data", logList);
		return map;
	}

	@Override
	public int addLog(Log log) {
		return logDao.addLog(log);
	}

	@Override
	public List<Log> selectLogByLogTime(Date startTime, Date stopTime) {
		return logDao.selectLogByLogTime(startTime, stopTime);
	}

	@Override
	public int deleteLogByLogTime(Date startTime, Date stopTime) {
		return logDao.deleteLogByLogTime(startTime, stopTime);
	}


}
